package ten.test_10_10;

import java.util.Scanner;

public class TestMain3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] a = new int[n ];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < q; i++) {
            int op = sc.nextInt();
            int l = sc.nextInt();
            int r = sc.nextInt();
            if (op == 1) {
                int sum = 0;
                for (int j = l - 1; j < r; j++) {
                    sum |= (a[j] & a[j + 1]);
                }
                System.out.println(sum);
            } else if (op == 2) {
                int sun = 0;
                for (int j = l - 1; j < r; j++) {
                    sun &= (a[j] | a[j + 1]);

                }
                System.out.println(sun);
            }
        }
    }
}
